import './App.css';
import { BrowserRouter as Router, Routes, Route, Navigate } from 'react-router-dom';
import Login from './components/Login';
import Register from './components/Register';
import Dashboard from './components/Dashboard';
import UserInfoSetup from './components/UserInfoSetup';
import PrivateRoute from './components/PrivateRoute';
import HomePage from './components/HomePage';
import ArticleDetail from './components/ArticleDetail';
import AuthorPage from './components/AuthorPage';
import CreateArticlePage from './components/CreateArticlePage';

function App() {
  return (
    <Router>
      <div className="App">
        <Routes>
          {/* 默认路由指向主页 */}
          <Route path="/" element={<HomePage />} />
          
          {/* 登录和注册页面 */}
          <Route path="/login" element={<Login />} />
          <Route path="/register" element={<Register />} />
          <Route path="/user-info-setup" element={<UserInfoSetup />} />
          
          {/* 文章详情页面 */}
          <Route path="/article/:workId" element={<ArticleDetail />} />
          
          {/* 作者页面 */}
          <Route path="/author/:userId" element={<AuthorPage />} />
          
          {/* 受保护的路由 */}
          <Route 
            path="/dashboard" 
            element={
              <PrivateRoute>
                <Dashboard />
              </PrivateRoute>
            } 
          />
          <Route 
            path="/create-article" 
            element={
              <PrivateRoute>
                <CreateArticlePage />
              </PrivateRoute>
            } 
          />
        </Routes>
      </div>
    </Router>
  );
}

export default App;
